package com.example.travel.controller;

import com.example.travel.pojo.orm.UserMessage;
import com.example.travel.service.UserMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class MessageController {
    @Autowired
    private UserMessageService userMessageService;

    @GetMapping("/message/get_message")
    public List<UserMessage> getUserMessage(@RequestParam("fromId")Integer fromId, @RequestParam("toId")Integer toId){
        List<UserMessage> userMessages = userMessageService.getMessageByFromToId(fromId,toId);
        for (UserMessage userMessage : userMessages) {
            System.out.println(userMessage.toString());
        }
        return userMessages;
    }
}
